<div id="column-right">
    <?php echo $this->element('sidebar'); ?>
</div>
<div id="content">
    <?php if (!empty($order)) { ?>
        <style type="text/css">
            .table {
                width: 99% !important;
            }
        </style>
        <table class="table" cellpadding="0" cellspacing="0">
            <tbody><tr>
                    <td>
                        <div class="breadcrumb" style="margin-left:10px;padding:20px 0">
                            <?php echo $this->Html->link('Account Maintenance', array('controller' => 'User', 'action' => 'userinfo')); ?>
                            &nbsp;
                            &gt;&gt;&nbsp;Order Infomation
                        </div>
                    </td>
                </tr>
            </tbody></table>
        <table style="margin-top:20px;" class="table" cellpadding="0" cellspacing="0">
            <tbody><tr>
                    <td>
                        <h2 class="title1">Purchase Order</h2>
                        <p>3DArcShop
                        </p>
                    </td>
                </tr>
            </tbody></table>
        <div style="margin:15px 0">
            <p style="font-weight:bold;font-family:verdana">You have 2 times download for each link, Please download carefully.</p>
            <?php
            if ($order['Order']['payment_status'] == '1') {
                if (!empty($order_detail)) {
                    foreach ($order_detail as $key => $value) {
                        ?>
                        <div style="overflow:hidden;margin:5px 0;">
                            <p style="font-weight:bold;font-family:verdana;text-transform: uppercase"><?php echo $value['Product']['name']; ?></p>
                            <div style="font-weight:bold;font-family:verdana">
                                <p>
                                    DOWNLOAD <span style="text-transform: uppercase"><?php echo $value['Product']['name']; ?></span> :<br>
                                    <?php if (!empty($value['ProductLink'])) {
                                        foreach ($value['ProductLink'] as $link) {
                                            ?>
                                            <a href="<?php echo DOMAIN . 'User/download?order_id=' . $order['Order']['id'] . "&product_link_id=" . $link['ProductLink']['id']; ?>"> <?php echo $link['ProductLink']['link_name']; ?>
                                            </a><br/>
                                        <?php }
                                    }
                                    ?>
                                </p></div>
                        </div>
                    <?php
                    }
                }
            } else {
                ?>
                <p style="text-align:center;margin:15px 0">
                    <?php
                    echo $this->Html->link(
                            $this->Html->image(DOMAIN . 'images/paypal.gif', array('alt' => 'Payment via Paypal')), array('controller' => 'Paypal', 'action' => 'pay_by_order', $order['Order']['id']), array('escape' => false)
                    );
                    ?>
                </p>
    <?php } ?>
        </div>
        <p class="order-information">Order Information</p>
        <table class="table" cellpadding="0" cellspacing="0">    
            <tr>
                <td>Order Number</td>
                <td><?php echo $order['Order']['id']; ?></td>
            </tr>
            <tr>
                <td>Order Date</td>
                <td><?php echo $order['Order']['created']; ?></td>
            </tr>
            <tr>
                <td>Order Status</td>
                <td>
                    <?php
                    if ($order['Order']['payment_status'] == '1')
                        echo 'Completed';
                    else if ($order['Order']['payment_status'] == '2')
                        echo 'Failed';
                    else
                        echo 'Pedding';
                    ?>
                </td>
            </tr>
            </tbody></table>

        <table style="margin-top:20px;width:300px;" class="table" cellpadding="0" cellspacing="0">
            <tbody><tr>
                    <td style="width:49%;padding:6px">
                        <table class="table" style="width: 100% !important;" cellpadding="0" cellspacing="0">
                            <tbody>
                            <tr>
                                    <td colspan="2"><b>Bill To</b></td>
                                </tr>
                                <tr>
                                    <td>Email</td>
                                    <td><p style="width:190px;overflow:hidden"><?php echo $order['User']['email']; ?></p></td>
                                </tr>
                                <tr>
                                    <td>Company Name</td>
                                    <td><?php echo $order['User']['company_name']; ?></td>
                                </tr>
                                <tr>
                                    <td>Title</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Ful Name</td>
                                    <td><?php echo $order['User']['fullname']; ?></td>
                                </tr>
                                <tr>
                                    <td>Address 1</td>
                                    <td><?php echo $order['User']['address']; ?></td>
                                </tr>
                                <tr>
                                    <td>Address 2</td>
                                    <td><?php echo $order['User']['address2']; ?></td>
                                </tr>
                                <tr>
                                    <td>City</td>
                                    <td><?php echo $order['User']['city']; ?></td>
                                </tr>
                                <tr>
                                    <td>Zip/Postal Code</td>
                                    <td><?php echo $order['User']['zipcode']; ?></td>
                                </tr>
                                <tr>
                                    <td>State/Province</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Country</td>
                                    <td><?php echo $order['User']['country']; ?></td>
                                </tr>
                                <tr>
                                    <td>Phone</td>
                                    <td><?php echo $order['User']['phone']; ?></td>
                                </tr>
                            </tbody></table>
                    </td>
                    <td style="width:49%;padding:6px">
                        <table class="table" style="width: 100% !important;" cellpadding="0" cellspacing="0">
                            <tbody><tr>
                                    <td colspan="2"><b>Ship To</b></td>
                                </tr>
                                <tr>
                                    <td>Email</td>
                                    <td><p style="width:190px;overflow:hidden"><?php echo $order['User']['email']; ?></p></td>
                                </tr>
                                <tr>
                                    <td>Company Name</td>
                                    <td><?php echo $order['User']['company_name']; ?></td>
                                </tr>
                                <tr>
                                    <td>Title</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Full Name</td>
                                    <td><?php echo $order['User']['fullname']; ?></td>
                                </tr>
                                <tr>
                                    <td>Address 1</td>
                                    <td><?php echo $order['User']['address']; ?></td>
                                </tr>
                                <tr>
                                    <td>Address 2</td>
                                    <td><?php echo $order['User']['address2']; ?></td>
                                </tr>
                                <tr>
                                    <td>City</td>
                                    <td><?php echo $order['User']['city']; ?></td>
                                </tr>
                                <tr>
                                    <td>Zip/Postal Code</td>
                                    <td><?php echo $order['User']['zipcode']; ?></td>
                                </tr>
                                <tr>
                                    <td>State/Province</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Country</td>
                                    <td><?php echo $order['User']['country']; ?></td>
                                </tr>
                                <tr>
                                    <td>Phone</td>
                                    <td><?php echo $order['User']['phone']; ?></td>
                                </tr>
                            </tbody></table>
                    </td>
                </tr>
            </tbody></table>
        <table class="table" cellpadding="0" cellspacing="0" style="margin-top: -1px; border: 1px solid #E5E5E5;">
            <tbody>
            <tr>
                <th style="padding: 5px 10px; border: 1px solid #E5E5E5;">Qty</th>
                <th style="padding: 5px 10px; border: 1px solid #E5E5E5;">Name</th>
                <th style="padding: 5px 10px; border: 1px solid #E5E5E5;">SKU</th>
                <th style="padding: 5px 10px; border: 1px solid #E5E5E5;">Price</th>
                <th style="padding: 5px 10px; border: 1px solid #E5E5E5;">Total</th>
            </tr>
                <?php
                $total_amout = 0;
                if (!empty($order_detail)) {
                    foreach ($order_detail as $key => $value) {
                        $amount = $value['Product']['price'] * $value['OrderDetail']['number_product'];
                        $total_amout += $amount;
                        ?>
                        <tr>
                            <td><?php echo $key + 1; ?></td>
                            <td><?php echo $value['Product']['name']; ?></td>
                            <td><?php echo $value['Product']['code']; ?></td>
                            <td><?php echo $value['Product']['price']; ?> </td>
                            <td><?php echo number_format($amount); ?></td>
                        </tr>
        <?php }
    }
    ?>
                <!--
                <tr>
                    <td colspan="4" style="height:20px;"> </td>
                    <td> </td>
                </tr>
                -->
                <tr>
                    <td colspan="4" align="right"><strong>SubTotal: </strong></td>
                    <td><?php echo number_format($total_amout); ?></td>
                </tr>
                <tr>
                    <td colspan="4" align="right"><strong>Shipping and Handling Fee: </strong></td>
                    <td>0</td>
                </tr>
                <!--
                <tr>
                    <td colspan="4" style="height:25px;"></td>
                    <td></td>
                </tr>
                -->
                <tr>
                    <td colspan="4" align="right"><strong style="color:#F00;">Total: </strong></td>
                    <td><?php echo number_format($total_amout); ?></td>
                </tr>
                <!--
                <tr>
                    <td colspan="4" style="height:25px;"></td>
                    <td></td>
                </tr>
                <tr>
                    <td colspan="4" style="height:20px;"></td>
                    <td></td>
                </tr>
                -->
            </tbody>
        </table>

        <table class="table" style="margin-top:-1px; border: 1px solid #E5E5E5;" cellpadding="0" cellspacing="0">
            <tbody>
                <tr>
                    <th colspan="2" style="padding: 5px 10px;">
                        Payment Information
                    </th>
                </tr>
                <tr>
                    <td>Payment Method :</td>
                    <td>PayPal / Credit Card </td>
                </tr>
            </tbody>
        </table>

<?php } ?>
</div><!--end .content-->